package org.erp.product.router;

import org.erp.product.domain.dto.ConnectActionDto;
import org.erp.product.infrastructure.enums.ConnectEventEnum;
import org.erp.product.infrastructure.exception.ProductException;
import org.erp.product.strategy.ConnectActionStrategy;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @author libin
 * @version 1.0
 * @description:
 * @date 2025/11/25 23:33
 **/
@Component
public class ConnectActionFacade {

    @Resource
    private Map<String, ConnectActionStrategy> connectActionStrategyMap;

    public void action(ConnectActionDto connectActionDto) {
        ConnectActionStrategy strategy = connectActionStrategyMap.get(ConnectEventEnum.getByCode(connectActionDto.getConnectEvent()).name());
        if (strategy == null) {
            throw new ProductException("异常事件");
        }
        strategy.execute(connectActionDto.getIds());
    }
}
